#4212 generate teams#4271
Conversation
|
Everything else looks great! Just one tiny thing. |
|
|
||
| const leadPool = possibleLeads.filter((user) => user.userId !== head.userId); | ||
| const leads = this.faker.helpers.arrayElements(leadPool, this.faker.number.int({ min: 1, max: 3 })); | ||
| const teamMembers = this.faker.helpers.arrayElements(members, this.faker.number.int({ min: 8, max: 20 })); |
There was a problem hiding this comment.
Might be good to extract these magic numbers to the top so that it is easily configurable to the devs.
| const output = await instance.run(depOutputs); | ||
|
|
||
| outputs.set(instance.constructor.name, output); | ||
| Object.assign(context, output); |
There was a problem hiding this comment.
This silently clobbers any key that two processes share. The flat context returned at the end has no collision detection. If a future process returns a key that already exists (e.g. both emit organization or teams), the later value wins silently with no error. Either check for collisions before merging, or drop the flat context entirely and let callers use the typed per-process outputs from the Map
| throw new Error('TeamProcess could not find a head for a team.'); | ||
| } | ||
|
|
||
| const leadPool = possibleLeads.filter((user) => user.userId !== head.userId); |
There was a problem hiding this comment.
add cross-team exclusion , so the same user cannot end up as a lead on all 20 teams
| import { seedTeamConfigs, teamCreateInput } from '../factories/teams.factory.js'; | ||
| import { SeedProcess } from '../processes/seed-process.js'; | ||
|
|
||
| const EXPECTED_TEAM_COUNT = 20; |
There was a problem hiding this comment.
this needs to stay up to date with the length of seedTeamConfigs which makes it annoying to add another team if needed, just use sedTeamConfigs.length
| seedTeamConfigs.map((config, index) => { | ||
| const head = possibleHeads[index % possibleHeads.length]; | ||
|
|
||
| if (!head) { |
There was a problem hiding this comment.
change this to:
if (possibleHeads.length < seedTeamConfigs.length) {
throw new Error(`Not enough head candidates (${possibleHeads.length}) for ${seedTeamConfigs.length} teams.`);
}
| }, {}); | ||
|
|
||
| const possibleHeads = [...heads, ...admins, ...leadership]; | ||
| const possibleLeads = [...leadership, ...heads, ...admins]; |
There was a problem hiding this comment.
I don't understand the distinction between these two and if it's necessary
Changes
Added teams.factory and teams.process. Then added the process to our dev-seed.ts.
Checklist
It can be helpful to check the
ChecksandFiles changedtabs.Please review the contributor guide and reach out to your Tech Lead if anything is unclear.
Please request reviewers and ping on slack only after you've gone through this whole checklist.
yarn.lockchanges (unless dependencies have changed)Closes #4212